package com.work.yshop.utils;

import com.work.yshop.model.Product;

import java.util.ArrayList;
import java.util.List;

/**
 * 产品数据工具类
 * 集中管理产品数据，确保搜索功能和展示的数据一致性
 */
public class ProductDataUtils {

    private static List<Product> mockProducts;

    /**
     * 获取模拟产品数据
     * @return 产品列表
     */
    public static List<Product> getMockProductData() {
        if (mockProducts == null) {
            mockProducts = createMockProductData();
        }
        return new ArrayList<>(mockProducts);
    }

    /**
     * 创建模拟商品数据
     */
    private static List<Product> createMockProductData() {
        List<Product> products = new ArrayList<>();
        
        // 添加一些模拟商品数据
        Product product1 = new Product(1, "新鲜有机蔬菜 无农药绿色食品", "来自高山的有机蔬菜，无农药，绿色健康", 10.0, 12.0, "斤", 344, "https://images.pexels.com/photos/2286776/pexels-photo-2286776.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1");
        products.add(product1);
        
        Product product2 = new Product(2, "南阳优质面粉 东北特产", "东北特产面粉，口感细腻，营养丰富", 25.0, 30.0, "袋", 334, "https://images.pexels.com/photos/162825/flour-wheat-flour-wheat-food-162825.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1");
        products.add(product2);
        
        Product product3 = new Product(3, "东北花生米 红衣花生仁", "东北特产花生，颗粒饱满，香脆可口", 4.5, 5.5, "斤", 106, "https://images.pexels.com/photos/4110251/pexels-photo-4110251.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1");
        product3.setNew(true); // 设置为新品
        products.add(product3);
        
        Product product4 = new Product(4, "野生纯绿色土豆 农家自种", "农家自种土豆，口感绵软，富含营养", 45.0, 52.0, "袋", 752, "https://images.pexels.com/photos/2286776/pexels-photo-2286776.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1");
        products.add(product4);
        
        Product product5 = new Product(5, "金秋梨香 金秋梨蜜", "金秋梨香，果肉细腻，汁水丰富", 12.0, 15.0, "斤", 493, "https://images.pexels.com/photos/1132047/pexels-photo-1132047.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1");
        products.add(product5);
        
        Product product6 = new Product(6, "泰国金枕头榴莲 香甜可口", "泰国进口金枕头榴莲，肉质细腻，香甜可口", 80.0, 100.0, "个", 210, "https://images.pexels.com/photos/1435735/pexels-photo-1435735.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1");
        products.add(product6);
        
        Product product7 = new Product(7, "云南红提 新鲜水果", "云南特产红提，颗粒饱满，甜蜜多汁", 15.8, 18.0, "斤", 432, "https://images.pexels.com/photos/708777/pexels-photo-708777.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1");
        products.add(product7);
        
        Product product8 = new Product(8, "海南菠萝 新鲜热带水果", "海南特产菠萝，果肉金黄，酸甜可口", 9.9, 12.0, "个", 367, "https://images.pexels.com/photos/947879/pexels-photo-947879.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1");
        products.add(product8);
        
        Product product9 = new Product(9, "新疆和田大枣 特级红枣", "新疆和田大枣，肉厚核小，营养丰富", 28.5, 35.0, "袋", 289, "https://images.pexels.com/photos/1435735/pexels-photo-1435735.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1");
        product9.setNew(true); // 设置为新品
        products.add(product9);
        
        Product product10 = new Product(10, "四川红心猕猴桃 奇异果", "四川特产红心猕猴桃，果肉细腻，营养丰富", 6.8, 8.0, "个", 521, "https://images.pexels.com/photos/51312/kiwi-fruit-vitamins-healthy-eating-51312.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1");
        products.add(product10);
        
        // 添加更多商品数据
        Product product11 = new Product(11, "有机胡萝卜 新鲜蔬菜", "有机种植，富含胡萝卜素，健康美味", 3.5, 4.5, "斤", 215, "https://images.pexels.com/photos/143133/pexels-photo-143133.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1");
        products.add(product11);
        
        Product product12 = new Product(12, "新鲜西红柿 农家自种", "农家自种西红柿，酸甜可口，营养丰富", 5.0, 6.0, "斤", 328, "https://images.pexels.com/photos/1327838/pexels-photo-1327838.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1");
        products.add(product12);
        
        Product product13 = new Product(13, "绿色青椒 无公害蔬菜", "绿色种植，无公害，口感脆嫩", 4.0, 4.8, "斤", 187, "https://images.pexels.com/photos/1435904/pexels-photo-1435904.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1");
        products.add(product13);
        
        Product product14 = new Product(14, "新鲜茄子 农家种植", "农家种植茄子，肉质细腻，口感鲜美", 3.8, 4.5, "斤", 201, "https://images.pexels.com/photos/321551/pexels-photo-321551.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1");
        products.add(product14);
        
        Product product15 = new Product(15, "有机黄瓜 新鲜蔬菜", "有机种植黄瓜，脆嫩多汁，清香可口", 4.2, 5.0, "斤", 245, "https://images.pexels.com/photos/3568039/pexels-photo-3568039.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1");
        products.add(product15);
        
        return products;
    }
    
    /**
     * 创建更多模拟商品数据（用于加载更多）
     */
    public static List<Product> createMoreProductData() {
        List<Product> products = new ArrayList<>();
        
        // 添加额外的商品数据
        int startId = 16;
        for (int i = 0; i < 10; i++) {
            int id = startId + i;
            Product product = new Product(
                id,
                "农产品" + id + " 新鲜直供",
                "来自农村的新鲜农产品，绿色健康，无污染",
                5.0 + i * 2.5,
                8.0 + i * 2.5,
                "斤",
                100 + i * 50,
                "https://images.pexels.com/photos/1327838/pexels-photo-1327838.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1"
            );
            
            if (i % 3 == 0) {
                product.setNew(true); // 设置部分商品为新品
            }
            
            products.add(product);
        }
        
        return products;
    }
} 